// TOWN SCRIPT
//    Town 8: Under Hetware

// This is the special encounter script for this town.
// The states INIT_STATE, EXIT_STATE, and START_STATE have
// meanings that are described in the documenation. States you write
// yourself should be numbered from 10-100.
//Problems with missing if clauses deferred till later.
begintownscript;

variables;

short i,j,k,r1,choice;

body;

beginstate INIT_STATE;
// This state called whenever this town is entered.
	set_name(6,"Aeschere");
	set_state_continue(18);
break;

beginstate EXIT_STATE;
// Always called when the town is left.
break;

beginstate START_STATE;
// This state is called every turn the party is in this town.
break;

beginstate 10;
	block_entry(1);
	reset_dialog_preset_options(5);
	choice = run_dialog(0);
	if (choice == 2) {
		move_to_new_town(7,11,41);
		end();
		}
break;

beginstate 11;
	if (is_combat()) {
	block_entry(1); 
	end();
}
	set_state_continue(12);
break;

beginstate 12;
	reset_dialog();
	add_dialog_str(0,"A narrow crevice in the cave wall leads onward. If you go on, you probably won't be able to get back easily.",0);
	add_dialog_choice(0,"Leave.");
	add_dialog_choice(1,"Onward.");
	choice = run_dialog(1);
	if (choice == 2)
		set_state_continue(14);
	block_entry(1);
break;

beginstate 14;
	teleport_party(20,33,1);
break;

beginstate 15;
	if (get_flag(8,1) == 250)
		end();
	message_dialog("You find yourself down in a small cavern, with a narrow winding passage leading northwest. Aeschere is somewhere down here. Dracan's words come back to you...",
	  "_Track him down and dispose of him. Do not listen to his ramblings. Do not return before your task is accomplished. We await your success with a generous reward._");
	set_flag(8,1,250);
break;

beginstate 16;
	set_flag(100,0,8);
break;

beginstate 17;
	set_flag(100,0,11);
break;

beginstate 18;
	if (get_flag(100,0) < 9) 
	activate_hidden_group(1);
break;

beginstate 20;
	if (get_flag(108,1) == 250)
		end();
	message_dialog("These barracks appear to have been recently active, but currently empty.","");
	set_flag(108,1,250);
break;

beginstate 23;
	message_dialog("You strike down Aeschere. The mission appears to have been accomplished, although you can't help but feel a little guilty of not even having to fight for it.","");
	set_flag(100,0,11);
	set_flag(100,9,1);
break;

beginstate 24;
	if (get_flag(108,0) == 250)
		end();
	reset_dialog();
	add_dialog_str(0,"You are tripped by a cleverly concealed rope. As you thud against the ground, cursing whoever set the trap, you hear the unmistakable drawing of steel. Before you can react, you feel the blades at the back of your necks.",0);
	add_dialog_str(1,"Casually, Aeschere passes the throng of soldiers and walks up to you. His face contorts into a mischievous smile.",0);
	add_dialog_str(2,"_So innocent. So foolish. I suppose a delivery into the hands of the Falcon-lords would not be inappropriate. I may not be Dracan's tool, but neither shall I leave my fate at the bloodied hands of mercenaries._",0);
	add_dialog_str(3," * * *",0);
	add_dialog_str(4,"The cell in Hengest is dark, dank, and chill. The stale air passes through you uncomfortably as you contemplate your fate.",0);
	add_dialog_choice(0,"OK.");
	choice = run_dialog(1);
	set_flag(108,0,250);
	set_state_continue(25);
break;

beginstate 25;
	set_flag(100,0,12);
	change_outdoor_location(1,0,23,13);
	block_entry(1);
	move_to_new_town(18,29,38);
	end();
break;

beginstate 27;
	if (get_flag(100,0) < 11) 
		set_state_continue(24);
break;

beginstate 28;
	if (get_flag(100,0) < 11) 
		set_state_continue(29);
break;

beginstate 29;
	if (character_in_party(1702) >= 0) 
		set_state_continue(30);
break;

beginstate 30;
	if (get_flag(97,7) == 250)
		end();
	message_dialog("Fernow suddenly shakes her head. _I don't believe him at all. There's a trap ahead. I can sense it._","");
	set_flag(97,7,250);
break;

beginstate 31;
	if (get_flag(195,3) == 250)
		end();
	reset_dialog();
	add_dialog_str(0,"You step into a small but well-arranged room. Wooden chairs are set around a long table. The chairs are all empty, except for one at the far end. From it, the familiar face of Aeschere gives you a weak smile.",0);
	add_dialog_choice(0,"OK.");
	choice = run_dialog(1);
	set_flag(195,3,250);
break;

beginstate 32;
	reset_dialog();
	add_dialog_str(0,"A short note in the Seawyrm-glyphs has been attached to the wall. The letters are somewhat more familiar to you, now that you've been to Ingusi and seen quite a few of these signs. It reads:",0);
	add_dialog_str(1,"AGENTS -",0);
	add_dialog_str(2,"     Deal with Aeschere in the swiftest manner possible. Do not let him delay you. Remember: this is the best opportunity to fulfill your mission. We await you outside to deliver the payment.",0);
	add_dialog_str(3,"     We trust that you shall be sufficiently decisive.",0);
	add_dialog_choice(0,"OK.");
	choice = run_dialog(1);
break;

beginstate 33;
	if (get_flag(100,0) >= 11)
		set_state_continue(34);
break;

beginstate 34;
	if (get_flag(195,6) == 250)
		end();
	if (reward_give(310) > 0) {
		set_flag(195,6,250);
		change_coins(100);
		}
	set_state_continue(35);
break;

beginstate 35;
	reset_dialog();
	add_dialog_str(0,"Several agents are camped just outside the cave's exit. When they see you, they spring to their feet. Asking you briefly whether your task was accomplished, they nod and hand you a small sack of valuables.",0);
	add_dialog_str(1,"_This is all we have with us,_ a vaguely recognizable voice speaks. _Return to Ingusi, and you shall be amply compensated. There are yet more tasks, with greater rewards. We will await you._",0);
	add_dialog_str(2,"Deeming the conversation finished, the agents mount and depart.",0);
	add_dialog_choice(0,"OK.");
	choice = run_dialog(1);
break;

